import { defineStore } from "pinia";
import { ref } from "vue";

export const useConsuleationStore = defineStore(
  "w-z-j-l",
  () => {
    const consult = ref({});
    // 设置问诊类型
    const setType = (type) => (consult.value.type = type);
    // 激素问诊的类型
    const setIllnessType = (type) => (consult.value.illnessType = type);
    // 科室
    const setDep = (id) => (consult.value.depId = id);
    // 病情描述
    const setIllness = (illness) => {
      consult.value.illnessDesc = illness.illnessDesc;
      consult.value.illnessTime = illness.illnessTime;
      consult.value.consultFlag = illness.consultFlag;
      consult.value.pictures = illness.pictures;
    };
    // 设置患者
    const setPatient = (id) => (consult.value.patientId = id);
    // 设置优惠券
    const setCoupon = (id) => (consult.value.couponId = id);
    // 清空记录
    const clear = () => (consult.value = {});
    return {
      consult,
      setType,
      setIllnessType,
      setDep,
      setIllness,
      setPatient,
      setCoupon,
      clear,
    };
  },
  {
    persist: true,
  }
);
